<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.0: http://docutils.sourceforge.net/" />
<title>vb2Py - User Types</title>
<link rel="stylesheet" href="default.css" type="text/css" />
</head>
<body>
<div class="document" id="vb2py-user-types">
<h1 class="title">vb2Py - User Types</h1>
<!-- filename: c:\development\python22\lib\site-packages\vb2py\doc/type.htm -->
<p>Contents of this page:</p>
<ul class="simple">
<li><a class="reference" href="#general">General</a></li>
<li><a class="reference" href="#default-conversion">Default Conversion</a></li>
<li><a class="reference" href="#list-of-options">List of Options</a></li>
</ul>
<div class="section" id="general">
<h1><a name="general">General</a></h1>
<p>VB has the concept of a user <tt class="literal"><span class="pre">Type</span></tt>. A user can define a <tt class="literal"><span class="pre">Type</span></tt> which can then be used to define variables which have one or more <em>properties</em>, each with its own type. The closest Python equivalent is a bare class. VB User <tt class="literal"><span class="pre">Types</span></tt> are converted to bare classes with the appropriate properties. When a user <tt class="literal"><span class="pre">Type</span></tt> is used, an istance of the class is created in the Python code.</p>
<p>Class properties are defined in an <tt class="literal"><span class="pre">__init__</span></tt> method to avoid having mutable class properties.</p>
</div>
<div class="section" id="default-conversion">
<h1><a name="default-conversion">Default Conversion</a></h1>
<p>VB:</p>
<pre class="literal-block">
Type Point
    X As Single
    Y As Single
End Type
'
Type Line2D
    Start As Point
    Finish As Point
End Type
'
Dim p1 As Point, p2 As Point
p1.X = 10
p1.Y = 20
p2.X = 30
p3.Y = 40
'
Dim l1 As Line2D
l1.Start = p1
l1.Finish = p2
</pre>
</div>
<div class="section" id="list-of-options">
<h1><a name="list-of-options">List of Options</a></h1>
<p>There are no options specific to the <tt class="literal"><span class="pre">Type</span></tt> statement.</p>
</div>
</div>
</body>
</html>
